package com.ff.device.exception;

import com.ff.device.result.CodeMsg;
import com.ff.device.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class CustomControllerAdvice {


    @ResponseBody
    @ExceptionHandler(value=CustomException.class)
    public Result<String> errorHandler(CustomException ex){
        return Result.error(ex.getCodeMsg());
    }

    @ResponseBody
    @ExceptionHandler(value=Exception.class)
    public Result<String> errorHandler(Exception ex){
          return Result.error(CodeMsg.BIND_ERROR.fillArgs(ex.getMessage()));
    }

}
